package b.i.c.b;

import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import java.lang.reflect.Method;
import org.xmlpull.v1.XmlPullParser;

/* compiled from: ResourcesCompat */
public final class h {

    /* compiled from: ResourcesCompat */
    public static class a {
        public static final Object a = new Object();
        public static Method b;
        public static boolean c;
    }

    public static a a(TypedArray typedArray, XmlPullParser xmlPullParser, Theme theme, String str, int i, int i2) {
        if (c(xmlPullParser, str)) {
            TypedValue typedValue = new TypedValue();
            typedArray.getValue(i, typedValue);
            int i3 = typedValue.type;
            if (i3 >= 28 && i3 <= 31) {
                return new a(null, null, typedValue.data);
            }
            a a;
            try {
                a = a.a(typedArray.getResources(), typedArray.getResourceId(i, 0), theme);
            } catch (Exception e) {
                Log.e("ComplexColorCompat", "Failed to inflate ComplexColor.", e);
                a = null;
            }
            if (a != null) {
                return a;
            }
        }
        return new a(null, null, i2);
    }

    public static String b(TypedArray typedArray, XmlPullParser xmlPullParser, String str, int i) {
        if (c(xmlPullParser, str)) {
            return typedArray.getString(i);
        }
        return null;
    }

    public static boolean c(XmlPullParser xmlPullParser, String str) {
        return xmlPullParser.getAttributeValue("http://schemas.android.com/apk/res/android", str) != null;
    }

    /* JADX WARNING: Removed duplicated region for block: B:30:0x00b4  */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x00b9 A:{SKIP} */
    public static android.graphics.Typeface d(android.content.Context r16, int r17, android.util.TypedValue r18, int r19, b.i.c.b.g r20, android.os.Handler r21, boolean r22) {
        /*
        r9 = r17;
        r0 = r18;
        r5 = r19;
        r10 = r20;
        r11 = r21;
        r3 = r16.getResources();
        r1 = 1;
        r3.getValue(r9, r0, r1);
        r12 = "ResourcesCompat";
        r1 = r0.string;
        if (r1 == 0) goto L_0x00d9;
    L_0x0018:
        r13 = r1.toString();
        r0 = "res/";
        r0 = r13.startsWith(r0);
        r14 = 0;
        r15 = -3;
        if (r0 != 0) goto L_0x002d;
    L_0x0026:
        if (r10 == 0) goto L_0x00b7;
    L_0x0028:
        r10.a(r15, r11);
        goto L_0x00b7;
    L_0x002d:
        r0 = b.i.d.d.b;
        r1 = b.i.d.d.c(r3, r9, r5);
        r0 = r0.a(r1);
        r0 = (android.graphics.Typeface) r0;
        if (r0 == 0) goto L_0x0043;
    L_0x003b:
        if (r10 == 0) goto L_0x0040;
    L_0x003d:
        r10.b(r0, r11);
    L_0x0040:
        r14 = r0;
        goto L_0x00b7;
    L_0x0043:
        r0 = r13.toLowerCase();	 Catch:{ XmlPullParserException -> 0x009d, IOException -> 0x0087 }
        r1 = ".xml";
        r0 = r0.endsWith(r1);	 Catch:{ XmlPullParserException -> 0x009d, IOException -> 0x0087 }
        if (r0 == 0) goto L_0x0075;
    L_0x004f:
        r0 = r3.getXml(r9);	 Catch:{ XmlPullParserException -> 0x009d, IOException -> 0x0087 }
        r2 = b.i.b.f.H0(r0, r3);	 Catch:{ XmlPullParserException -> 0x009d, IOException -> 0x0087 }
        if (r2 != 0) goto L_0x0064;
    L_0x0059:
        r0 = "Failed to find font-family tag";
        android.util.Log.e(r12, r0);	 Catch:{ XmlPullParserException -> 0x009d, IOException -> 0x0087 }
        if (r10 == 0) goto L_0x00b7;
    L_0x0060:
        r10.a(r15, r11);	 Catch:{ XmlPullParserException -> 0x009d, IOException -> 0x0087 }
        goto L_0x00b7;
    L_0x0064:
        r1 = r16;
        r4 = r17;
        r5 = r19;
        r6 = r20;
        r7 = r21;
        r8 = r22;
        r14 = b.i.d.d.a(r1, r2, r3, r4, r5, r6, r7, r8);	 Catch:{ XmlPullParserException -> 0x009d, IOException -> 0x0087 }
        goto L_0x00b7;
    L_0x0075:
        r0 = r16;
        r0 = b.i.d.d.b(r0, r3, r9, r13, r5);	 Catch:{ XmlPullParserException -> 0x009d, IOException -> 0x0087 }
        if (r10 == 0) goto L_0x0040;
    L_0x007d:
        if (r0 == 0) goto L_0x0083;
    L_0x007f:
        r10.b(r0, r11);	 Catch:{ XmlPullParserException -> 0x009d, IOException -> 0x0087 }
        goto L_0x0040;
    L_0x0083:
        r10.a(r15, r11);	 Catch:{ XmlPullParserException -> 0x009d, IOException -> 0x0087 }
        goto L_0x0040;
    L_0x0087:
        r0 = move-exception;
        r1 = new java.lang.StringBuilder;
        r1.<init>();
        r2 = "Failed to read xml resource ";
        r1.append(r2);
        r1.append(r13);
        r1 = r1.toString();
        android.util.Log.e(r12, r1, r0);
        goto L_0x00b2;
    L_0x009d:
        r0 = move-exception;
        r1 = new java.lang.StringBuilder;
        r1.<init>();
        r2 = "Failed to parse xml resource ";
        r1.append(r2);
        r1.append(r13);
        r1 = r1.toString();
        android.util.Log.e(r12, r1, r0);
    L_0x00b2:
        if (r10 == 0) goto L_0x00b7;
    L_0x00b4:
        r10.a(r15, r11);
    L_0x00b7:
        if (r14 != 0) goto L_0x00d8;
    L_0x00b9:
        if (r10 == 0) goto L_0x00bc;
    L_0x00bb:
        goto L_0x00d8;
    L_0x00bc:
        r0 = new android.content.res.Resources$NotFoundException;
        r1 = "Font resource ID #0x";
        r1 = c.b.a.a.a.g(r1);
        r2 = java.lang.Integer.toHexString(r17);
        r1.append(r2);
        r2 = " could not be retrieved.";
        r1.append(r2);
        r1 = r1.toString();
        r0.<init>(r1);
        throw r0;
    L_0x00d8:
        return r14;
    L_0x00d9:
        r1 = new android.content.res.Resources$NotFoundException;
        r2 = "Resource \"";
        r2 = c.b.a.a.a.g(r2);
        r3 = r3.getResourceName(r9);
        r2.append(r3);
        r3 = "\" (";
        r2.append(r3);
        r3 = java.lang.Integer.toHexString(r17);
        r2.append(r3);
        r3 = ") is not a Font: ";
        r2.append(r3);
        r2.append(r0);
        r0 = r2.toString();
        r1.<init>(r0);
        throw r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: b.i.c.b.h.d(android.content.Context, int, android.util.TypedValue, int, b.i.c.b.g, android.os.Handler, boolean):android.graphics.Typeface");
    }

    public static TypedArray e(Resources resources, Theme theme, AttributeSet attributeSet, int[] iArr) {
        if (theme == null) {
            return resources.obtainAttributes(attributeSet, iArr);
        }
        return theme.obtainStyledAttributes(attributeSet, iArr, 0, 0);
    }
}
